1 using UnityEngine;
2 using
System.Collections;
3
4 namespace
GamePlay
5 {
6     
public class NextGuideClickListener : InputAdapter
7     {
8         
public GameObject guideObject;
9         
public Sprite[] guides;
10
11         
private int guideIndex;
12
13         
public void Start()
14         {
15             gameObject.AddComponent<Actor>().addAction(
new ActionRepeat(ActionRepeat.FOREVER, new ActionSequence(
16                 
new ActionScaleTo(0.9f, 0.9f, 0.2f, Interpolation.sine),
17                 
new ActionScaleTo(1, 1, 0.2f, Interpolation.sine)
18                 )));
19             guideIndex =
0;
20         }
21
22         
public override void OnTouchDown()
23         {
24             
if (InputController.Name != InputNames.DIALOG) return;
25             
base.OnTouchDown();
26             gameObject.GetComponent<SpriteRenderer>().color =
new Color(0.5f, 0.5f, 0.5f, 1);
27             SoundManager.playButtonSound();
28         }
29         
public override void OnCheckUp()
30         {
31             
if (InputController.Name != InputNames.DIALOG) return;
32             
base.OnCheckUp();
33             gameObject.GetComponent<SpriteRenderer>().color =
new Color(1, 1, 1, 1);
34         }
35         
public override void OnTouchUp()
36         {
37             
if (InputController.Name != InputNames.DIALOG) return;
38             
base.OnTouchUp();
39             guideIndex++;
40             
if (guideIndex == 4)
41             {
42                 gameObject.transform.parent.gameObject.GetComponent<GuideLayer>().hideGuide();
43             }
44             
else
45             {
46                 guideObject.GetComponent<SpriteRenderer>().sprite = guides[guideIndex];
47             }
48         }
49     }
50 }



Trò chơi đua xe động vật trong UNITY Engine 114.693 lượt xem

Gõ tìm kiếm nhanh...